The VARYING OF CHAR user-defined types are a VSI Pascal
extension that provides a way of declaring variable-length
character strings with a compile-time maximum length. If you
require portable code, use the STRING predefined schema types to
specify variable-length character strings.
Syntax:
VARYING [upper-bound] OF [[attribute-list]] CHAR
The 'upper-bound' is an integer in the range from 1 through
65,535 that indicates the length of the longest possible string.
The 'attribute-list' is one or more optional identifiers that
provide additional information about the VARYING OF CHAR string
components.
To assign values to fixed-length character strings, you can use
a character-string constant (or an expression that evaluates to
a character string). When assigning into fixed-length strings,
the compiler adds blanks to extend a string shorter than the
maximum characters declared. If you specify a string longer
than the maximum characters declared, an error occurs. You can
also use an array constructor as long as you specify characters
for every component of the array as specified in the
declaration.
Although a VARYING OF CHAR is a distinct type, it possesses some
of the properties of both record and array types. A VARYING
string is actually stored as though it were a record with two
fields, LENGTH and BODY (which are predeclared identifiers in
VSI Pascal). The LENGTH field contains the length of the
current character string; the BODY field contains the string.
Either field can be accessed in the same way record fields are
accessed (VARY.LENGTH, VARY.BODY).
Example: VARYING [25] OF CHAR
This VARYING OF CHAR type could have the following values:
'Wolfgang Amadeus Mozart'
'Bach'